import java.util.Scanner;

/**
 * 用户服务
 *
 * @author yuwei
 * @date 20:13 2024/4/24
 */
public class attendanceInfoManage {
    static public void show(){
        System.out.println("1.查看考勤详情");
        System.out.println("2.打卡");
        System.out.println("3.返回");
        Scanner Scanner = new Scanner(System.in);
        switch (Scanner.nextInt()){
            case 1:
                info();
                show();
                break;
            case 2:
                sign();
                show();
                break;
            case 3:
                system.attendance();
                break;
        }
    }
    static public void sign(){
        System.out.println("输入名字");
        Scanner Scanner = new Scanner(System.in);
        String name = Scanner.next();
        for(int i =1;i<=attendanceTable.attendances.size();i++){
            System.out.println(i+".  "+attendanceTable.attendances.toArray()[i-1]);
        }
        if(attendanceTable.attendances.size()==0){
            System.out.println("    无任何数据 ");
            return;
        }
        System.out.println("输入考勤编号");
        int id = Scanner.nextInt();
        if(id>0&&id<=attendanceTable.attendances.size()){
            Attendance attendance = (Attendance) attendanceTable.attendances.toArray()[id-1];


                if( attendance.getList().add(name))
                    System.out.println("打卡成功");
                else System.out.println("已经打卡过了");
                return;

        }else{
            System.out.println("输入错误");
        }

    }
    public static void info(){
        for(int i =1;i<=attendanceTable.attendances.size();i++){
            System.out.println(i+".  "+attendanceTable.attendances.toArray()[i-1]);
        }
        if(attendanceTable.attendances.size()==0){
            System.out.println("    无任何数据 ");
            return;
        }
        System.out.println("输入考勤编号");
        Scanner Scanner = new Scanner(System.in);
        int id = Scanner.nextInt();
        if(id>0&&id<=attendanceTable.attendances.size()){
           Attendance attendance = (Attendance) attendanceTable.attendances.toArray()[id-1];
           attendance.getList().forEach(s-> System.out.println(s));
           if( attendance.getList().size()==0){
               System.out.println("无打卡记录");
           }
        }else{
            System.out.println("输入错误");
        }

    }
}
